package ConcurrentHashMap统计单词数量;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @ClassName: WordFileCreate
 * @Author: AllenSun
 * @Date: 2022/11/8 下午4:10
 */
public class WordFileCreate {
    static final String WORD_STR="abcdefghijklmnopqrstuvwxyz";

    public static void main(String[] args) throws IOException {
        int length = WORD_STR.length();
        int count = 200;
        List<String> list = new ArrayList<>(length*count);
        for (int i = 0; i < length; i++) {
            char word = WORD_STR.charAt(i);
            for (int j = 0; j < count; j++) {
                list.add(String.valueOf(word));
            }
        }
        Collections.shuffle(list);

        for (int i = 0; i < 26; i++) {
            String path = "tmp/" + (i + 1) + ".txt";
            File file = new File(path);
            if (!file.isFile()) {
                file.createNewFile();
            }
            BufferedWriter writer = new BufferedWriter(new FileWriter(path));
            String collect = list.subList(i * count, (i + 1) * count).stream()
                    .collect(Collectors.joining("\n"));
            writer.write(collect);
            writer.close();
        }
        
    }


}
